package ntu.metaweb.storage;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

public abstract class Rating implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4756217270109812294L;
	
	protected int rating;
	protected String rater;
	protected Date timestamp;
	
	protected Rating(String rater) {
		this.rating = 0;
		this.rater = rater;
		this.timestamp = Calendar.getInstance().getTime();
	}
	
	public Date getTimestamp() {
		return this.timestamp;
	}
	
	public String getRater() {
		return this.rater;
	}
	
	public int getRating() {
		return this.rating;
	}
	
	public abstract void setRating(int newRating);
	
	@Override
	public boolean equals(Object o) {
		if (!(o instanceof Rating)) {
			return false;
		}
		Rating r = (Rating) o;
		return this.rater.equals(r.rater);
	}
	
	@Override
	public int hashCode() {
		return this.rater.hashCode();
	}
}
